Page({

  data:{
    "m":'01',
    "d":'01',
    historyL:[],
    hid:true,
    up_show:false,
  },

  bindDateChange:function(event){
    var select = event.detail.value;
    var select_1 = select.split("-");
    this.setData({
      m:select_1[1],
      d:select_1[2],
    })
  },

getlist:function(event){
  this.setData({
    hid:false,
  })
  var that=this;
   wx.cloud.callFunction({
    name:'historylistseach',
    data:{
      start:this.data.historyL.length,
      count:10,
      m: this.data.m,
      d: this.data.d,
    },
  }).then(res=>{
    console.log(res);
    that.setData({
      historyL:that.data.historyL.concat(JSON.parse(res.result).result).reverse(),
      hid: true,
    });
  }).catch(err=>{
    console.error(err); 
  })
  
},
 

gotodetail: function(event){
  wx.navigateTo({
    url: `../detail/detail?historyid=${event.target.dataset.historyid}`,
  });
},

//监听画面滑动
onPageScroll:function(e){
  var that=this;
  if(e.scrollTop > 50){
    that.setData({
      up_show:true
    })
  }
  if(e.scrollTop < 50){
    that.setData({
      up_show:false
    })
  }
},
//点击置顶
gotop:function(e){
  if(wx.pageScrollTo){
    wx.pageScrollTo({
      scrollTop:0
    })
  }else{
    wx.showModal({
      title:'错误',
      content:'微信版本过低',
    })
  }
},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    return{
      title:'历史上的今天',
      path:'/pages/seach/seach',
      success:function(res){
        wx.showToast({
          title: '分享成功',
        })
      },
      fail:function(res){
        wx.showToast({
          title: '分享失败',
        })
      }
    }

  },

  toshare:function(res){
    return{
      title:'历史上的今天',
      path:'/pages/seach/seach/',
      success:function(res){
        wx.showToast({
          title: '分享成功',
        })
      },
      fail:function(res){
        wx.showToast({
          title: '分享失败',
        })
      }
    }
  }

})